
 var btn = document.getElementById("btn");
 var username = document.getElementById("username");
 var password = document.getElementById("password");
 var rpassword = document.getElementById("rpassword");
 var nickname = document.getElementById("nickname");

 btn.onclick = async function () {
       let url = "http://127.0.0.1:8888/users/register";
       let options = {
             type: "POST",
             headers: {
                
             },
             data: {
                   username:username.value,
                   password:password.value,
                   rpassword:rpassword.value,
                   nickname: nickname.value
             }
       };

       $.ajax(url, options)
       .done(function (data) {
             if (data.code === 1) {
                   alert("注册成功，马上为您跳转到登录页面");
                   setTimeout(function () {
                         location.href = "./login.html";
                   }, 1000)
             } else {
                   alert(data.message);
             }
       })
 }
